// pages/home/home.js
// 页面使用外部js
import {util} from '../../utils/util'
import { createStoreBindings } from 'mobx-miniprogram-bindings'
import { store } from '../../store/store'

Page({
  data: {
    title:"",
    deptList:[],
    swiperList:[],
    gridList:[]
  },
  onswiperClick(e){
    console.log('点击了轮播图');
  },
  loadGridList(){
    this.setData({
      gridList:[
        {name:"旅游",url:"/pages/info/info",src:"/images/png/ztc.png"},
        {name:"读书",url:"/pages/read/read",src:"/images/png/cx.png"},
        {name:"视频",url:"/pages/info/info",src:"/images/png/jc.png"},
        {name:"图片",url:"/pages/info/info",src:"/images/png/jdbf.png"},
        {name:"声音",url:"/pages/info/info",src:"/images/png/jhr.png"},
        {name:"学习",url:"/pages/info/info",src:"/images/png/jl.png"},
        {name:"工作",url:"/pages/info/info",src:"/images/png/rz.png"},
        {name:"爱情",url:"/pages/info/info",src:"/images/png/sb.png"},
        {name:"星座",url:"/pages/info/info",src:"/images/png/sc.png"}
      ]
    });
  },
  gridClick(e){
    let path=e.currentTarget.dataset.info+"?name=入参";
    console.log(e.currentTarget.dataset.info);
    // wx.switchTab({
    //   url: '/pages/message/message',
    // })
      wx.navigateTo({
        url: path,
      })
     
  },
  onSendWeb(e){   
    var vxM=this;
    wx.request({
      url: 'http://192.168.103.161:8890/api/DictDept/GetDictDept',
      method:'GET',
      data: {},
      header: {
        'content-type': 'application/json' // 默认值,
        ,'auth':'jhecis'
      },
      success (res) {
        console.log(res.data)
        vxM.setData({
          deptList:res.data.data

        });
      }
    })
    //请求结束
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.storeBindings = createStoreBindings(this, { // 这些绑定到this（此页面上）
      store, // 数据源
      fields: ['numA', 'numB', 'sum'] // 数据字段
     
    })
 
    util.sayHello('111111');
    this.onSendWeb();
    this.setData(
      {
        swiperList:[{name:"图1",src:"/images/s1.jpg"},{name:"图2",src:"/images/s2.jpg"}]
      } );
      //加载九宫格数据
      this.loadGridList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    this.storeBindings.detroyStoreBindings();
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})